"""This slot is used to filter invalid words or chars before analyzing the question.

Function 'handle' must be implemented which will be called in 'Robot'.
"""

import jieba
import jieba.posseg as pseg


class AnalyzeSlot:

    def handle(self, question):
        """Filter invalid words or chars in the question.

        Example:
            question: '台风的英文名是什么？(☆▽☆)'
            filter_question: '台风的英文名是什么？'
        
        Args:
            question (str): question from user.
        
        Returns:
            str: Filtered question.
        """
        words = self.tagging(question)
        return list(words)
    
    def tagging(self, question):
        """Use jieba for part of speech tagging on the question.
        
        Args:
            question (str): Question from user.
        
        Returns:
            [type]: [description]
        """
        words = pseg.cut(question)
        return words
